<%--
  Created by IntelliJ IDEA.
  User: S
  Date: 2022/1/4
  Time: 22:01
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <script type="text/javascript" src="js/jquery.min.js"></script>
</head>
<body>
<c:if test="${empty pu}">
    <script>location = "ShowPageServlet"</script>
</c:if>
<ul class="ul1">
    <c:forEach items="${pu.uis}" var="x">
        <li>部门：<span class="dn">${x.dept.deptname}</span>
            -----用户编号：<span class="uid">${x.userid}</span>
            -----用户姓名：<span class="un">${x.username}</span>
            -----用户年龄：<span class="nl">${x.userage}</span>&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="" class="xg"><span>修改</span></a><a href="" class="bc"><span>保存</span></a>
        </li>
    </c:forEach>
</ul>
<a href="ShowPageServlet?index=1">首页</a>
<a href="ShowPageServlet?index=${pu.index -1 }">上一页</a>
<a href="ShowPageServlet?index=${pu.index +1 }">下一页</a>
<a href="ShowPageServlet?index=${pu.pageTotalCount } ">尾页</a>
当前页${pu.index}页|共${pu.pageTotalCount}页
</body>
<script type="text/javascript">
    $(function () {
        $(".ul1 li a.bc").hide();
        $(".ul1 li a.xg").click(function () {
            $(this).hide();
            $(this).next().show();
            $(this).parent().children(".un").html("<input type='text' name='username' value=" + $(this).parent().children(".un").text() + " size=5>");
            $(this).parent().children(".uid").html("<input type='text' name='uid' value=" + $(this).parent().children(".uid").text() + " size=5>");
            $(this).parent().children(".nl").html("<input type='text' name='nl' value=" + $(this).parent().children(".nl").text() + " size=5>");
            return false;
        });
        $(".ul1 li a.bc").click(function(){
            $.get("UpdateUserServlet?userid=" + $(this).parent().children("span.uid").children().val()
                + "&username="+$(this).parent().children("span.un").children().val()
                + "&userage=" + $(this).parent().children("span.nl").children().val(),function(data){
                $(this).parents("ul").prev("span").text(data.msg);
                $(this).hide();
                $(this).prev().show();
                $(this).parent().children(".un").html($(this).parent().children("span.un").children().val());
                $(this).parent().children(".uid").html($(this).parent().children("span.uid").children().val());
                $(this).parent().children(".nl").html($(this).parent().children("span.nl").children().val());
            });
        });
    });
</script>
</html>